home *** CD-ROM | disk | FTP | other *** search
/ MACD 5 / MACD 5.bin / workbench / blankery / blanker / source / blankers / flyingtoaster / prefs.c < prev   
C/C++ Source or Header  |  1993-08-01  |  3KB  |  118 lines

  1. #include <exec/types.h>
  2. #include <exec/memory.h>
  3.  
  4. #include <intuition/intuition.h>
  5.  
  6. #include <libraries/gadtools.h>
  7. #include <dos/dos.h>
  8.  
  9. #include <clib/exec_protos.h>
  10. #include <clib/intuition_protos.h>
  11. #include <clib/gadtools_protos.h>
  12.  
  13. #include "FlyingToaster.h"
  14. #include "FlyingToaster_rev.h"
  15. #include "/defs.h"
  16.  
  17. struct mPrefObject {
  18.     LONG    Objects, Speed;
  19. };
  20.  
  21. VOID blank( VOID );
  22.  
  23.     struct    mPrefObject    nP;
  24. STATIC    const    UBYTE        VersTag[] = VERSTAG;
  25. extern    struct    Task        **Task;
  26. extern        UBYTE        *prefData;
  27.  
  28. #define    MAX_SPEED    3
  29. #define    MAX_OBJECTS    40
  30.  
  31. VOID setFlyingToasterPrefs( VOID )
  32. {
  33.         GT_SetGadgetAttrs( FlyingToasterGadgets[GD_OBJECTS], FlyingToasterWnd, 0L, GTSL_Level, nP.Objects , 0L );
  34.         GT_SetGadgetAttrs( FlyingToasterGadgets[GD_SPEED], FlyingToasterWnd, 0L, GTSL_Level, nP.Speed, 0L );
  35. }
  36.  
  37. int OKClicked( VOID )
  38. {
  39.     CopyMem( &nP, prefData, sizeof( struct mPrefObject ));
  40.     return( QUIT );
  41. }
  42.  
  43. int TESTClicked( VOID )
  44. {
  45.     *Task = FindTask( 0L );
  46.     blank();
  47.     return( CONTINUE );
  48. }
  49.  
  50. int CANCELClicked( VOID )
  51. {
  52.     return( QUIT );
  53. }
  54.  
  55. int SPEEDClicked( VOID )
  56. {
  57.     nP.Speed = FlyingToasterMsg.Code;
  58.     return( CONTINUE );
  59. }
  60.  
  61. int OBJECTSClicked( VOID )
  62. {
  63.     nP.Objects = FlyingToasterMsg.Code;
  64.     return( CONTINUE );
  65. }
  66.  
  67. int FlyingToasterVanillaKey( VOID )
  68. {
  69.     switch( FlyingToasterMsg.Code ) {
  70.     case 'o':
  71.         return( OKClicked() );
  72.     case 't':
  73.         return( TESTClicked() );
  74.     case 'c':
  75.         return( CANCELClicked() );
  76.     case 'a':
  77.         GT_SetGadgetAttrs( FlyingToasterGadgets[GD_OBJECTS], FlyingToasterWnd, 0L, GTSL_Level, ++(nP.Objects) > MAX_OBJECTS ?
  78.             nP.Objects = MAX_OBJECTS : nP.Objects, 0L );
  79.         return( CONTINUE );
  80.     case 'A':
  81.         GT_SetGadgetAttrs( FlyingToasterGadgets[GD_OBJECTS], FlyingToasterWnd, 0L, GTSL_Level, --(nP.Objects) < 1 ?
  82.             nP.Objects= 1 : nP.Objects, 0L );
  83.         return( CONTINUE );
  84.     case 's':
  85.         GT_SetGadgetAttrs( FlyingToasterGadgets[GD_SPEED], FlyingToasterWnd, 0L, GTSL_Level, ++(nP.Speed) > MAX_SPEED ?
  86.             nP.Speed = MAX_SPEED : nP.Speed, 0L );
  87.         return( CONTINUE );
  88.     case 'S':
  89.         GT_SetGadgetAttrs( FlyingToasterGadgets[GD_SPEED], FlyingToasterWnd, 0L, GTSL_Level, --(nP.Speed) < 1 ?
  90.             nP.Speed= 1 : nP.Speed, 0L );
  91.         return( CONTINUE );
  92.     default:
  93.         return( CONTINUE );
  94.     }
  95. }
  96.  
  97. VOID prefs( LONG command )
  98. {
  99.     switch( command ) {
  100.     case STARTUP:
  101.         CopyMem( prefData, &nP, sizeof( struct mPrefObject ));
  102.         if( !SetupScreen() ) {
  103.             if( !OpenFlyingToasterWindow()) setFlyingToasterPrefs();
  104.             CloseDownScreen();
  105.         }
  106.         break;
  107.     case IDCMP:
  108.         if( HandleFlyingToasterIDCMP() != QUIT ) break;
  109.     case KILL:
  110.         CloseFlyingToasterWindow();
  111.     }
  112. }
  113.  
  114. LONG winSig( VOID )
  115. {
  116.     return( FlyingToasterWnd ? 1L << FlyingToasterWnd->UserPort->mp_SigBit : 0L );
  117. }
  118.